<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.2.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/murmur/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/murmur/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/murmur/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/murmur/images/logo.svg" color="#222">

<link rel="stylesheet" href="/murmur/css/main.css">



<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.1/css/all.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.css">
  <script src="//cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.js"></script>

<script class="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"gitee.com","root":"/murmur/","scheme":"Gemini","version":"8.0.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":true,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":"disqus","storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}};
  </script>

  <meta name="description" content="基于CSS Grid布局实现城市排行榜的实践案例，通过grid-auto-flow属性设置布局算法">
<meta property="og:type" content="article">
<meta property="og:title" content="CSS Grid实现排行榜，控制网格的流动方向">
<meta property="og:url" content="https://gitee.com/lianghuilin/murmur.git/crush_notes/CSS%20Grid%E5%AE%9E%E7%8E%B0%E6%8E%92%E8%A1%8C%E6%A6%9C%EF%BC%8C%E6%8E%A7%E5%88%B6%E7%BD%91%E6%A0%BC%E7%9A%84%E6%B5%81%E5%8A%A8%E6%96%B9%E5%90%91/index.html">
<meta property="og:site_name" content="汇话板">
<meta property="og:description" content="基于CSS Grid布局实现城市排行榜的实践案例，通过grid-auto-flow属性设置布局算法">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/lianghuilin/blog-image-warehouse/raw/master/20220407143942.png">
<meta property="og:image" content="https://gitee.com/lianghuilin/blog-image-warehouse/raw/master/20220407151350.png">
<meta property="og:image" content="https://gitee.com/lianghuilin/blog-image-warehouse/raw/master/20220407151800.png">
<meta property="og:image" content="https://gitee.com/lianghuilin/blog-image-warehouse/raw/master/20220407151910.png">
<meta property="article:published_time" content="2022-04-07T07:34:00.000Z">
<meta property="article:modified_time" content="2022-04-08T14:38:20.227Z">
<meta property="article:author" content="William Leung">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/lianghuilin/blog-image-warehouse/raw/master/20220407143942.png">


<link rel="canonical" href="https://gitee.com/lianghuilin/murmur.git/crush_notes/CSS%20Grid%E5%AE%9E%E7%8E%B0%E6%8E%92%E8%A1%8C%E6%A6%9C%EF%BC%8C%E6%8E%A7%E5%88%B6%E7%BD%91%E6%A0%BC%E7%9A%84%E6%B5%81%E5%8A%A8%E6%96%B9%E5%90%91/">


<script class="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>CSS Grid实现排行榜，控制网格的流动方向 | 汇话板</title>
  


  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?a49081c570a782a242cdf6e19e1a584d";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <noscript>
  <style>
  body { margin-top: 2rem; }

  .use-motion .menu-item,
  .use-motion .sidebar,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header {
    visibility: visible;
  }

  .use-motion .header,
  .use-motion .site-brand-container .toggle,
  .use-motion .footer { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle,
  .use-motion .custom-logo-image {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line {
    transform: scaleX(1);
  }

  .search-pop-overlay, .sidebar-nav { display: none; }
  .sidebar-panel { display: block; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/murmur/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">汇话板</h1>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">设定目标，放慢步调，用温和的力量自我改革</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/murmur/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/murmur/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
  </ul>
</nav>




</div>
        
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <section class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%95%88%E6%9E%9C%E8%A6%81%E6%B1%82%E4%B8%8E%E6%80%9D%E8%80%83"><span class="nav-number">1.</span> <span class="nav-text">效果要求与思考</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%87%A0%E4%B8%AA%E6%B3%A8%E6%84%8F%E8%A6%81%E7%82%B9"><span class="nav-number">1.1.</span> <span class="nav-text">几个注意要点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Flex%E8%BF%98%E6%98%AFGrid"><span class="nav-number">1.2.</span> <span class="nav-text">Flex还是Grid</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9C%80%E7%BB%88%E6%A1%88%E4%BE%8B"><span class="nav-number">2.</span> <span class="nav-text">最终案例</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Grid%E5%B1%9E%E6%80%A7%E8%A7%A3%E8%AF%BB"><span class="nav-number">3.</span> <span class="nav-text">Grid属性解读</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#grid-template-columns%E8%AE%BE%E7%BD%AE%E7%BD%91%E6%A0%BC%E7%9A%84%E5%88%97%E5%AE%BD"><span class="nav-number">3.1.</span> <span class="nav-text">grid-template-columns设置网格的列宽</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#grid-auto-column%E8%AE%BE%E7%BD%AE%E9%9A%90%E5%BC%8F%E7%BD%91%E6%A0%BC"><span class="nav-number">3.2.</span> <span class="nav-text">grid-auto-column设置隐式网格</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#grid-auto-flow%E6%8E%A7%E5%88%B6%E5%B8%83%E5%B1%80%E7%AE%97%E6%B3%95"><span class="nav-number">3.3.</span> <span class="nav-text">grid-auto-flow控制布局算法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#grid-gap%E8%AE%BE%E7%BD%AE%E9%97%B4%E9%9A%94"><span class="nav-number">3.4.</span> <span class="nav-text">grid-gap设置间隔</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8F%82%E8%80%83"><span class="nav-number">4.</span> <span class="nav-text">参考</span></a></li></ol></div>
        </section>
        <!--/noindex-->

        <section class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">William Leung</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/murmur/archives">
          <span class="site-state-item-count">43</span>
          <span class="site-state-item-name">文章</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/murmur/categories/">
          
        <span class="site-state-item-count">9</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/murmur/tags/">
        <span class="site-state-item-count">1</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



        </section>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">
      

      

  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://gitee.com/lianghuilin/murmur.git/crush_notes/CSS%20Grid%E5%AE%9E%E7%8E%B0%E6%8E%92%E8%A1%8C%E6%A6%9C%EF%BC%8C%E6%8E%A7%E5%88%B6%E7%BD%91%E6%A0%BC%E7%9A%84%E6%B5%81%E5%8A%A8%E6%96%B9%E5%90%91/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/murmur/images/avatar.gif">
      <meta itemprop="name" content="William Leung">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="汇话板">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          CSS Grid实现排行榜，控制网格的流动方向
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2022-04-07 15:34:00" itemprop="dateCreated datePublished" datetime="2022-04-07T15:34:00+08:00">2022-04-07</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2022-04-08 22:38:20" itemprop="dateModified" datetime="2022-04-08T22:38:20+08:00">2022-04-08</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/murmur/categories/%E9%97%AA%E5%BF%B5%E7%AC%94%E8%AE%B0/" itemprop="url" rel="index"><span itemprop="name">闪念笔记</span></a>
        </span>
    </span>

  
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>1.9k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>2 分钟</span>
    </span>
</div>

            <div class="post-description">基于CSS Grid布局实现城市排行榜的实践案例，通过grid-auto-flow属性设置布局算法</div>
        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h2 id="效果要求与思考"><a href="#效果要求与思考" class="headerlink" title="效果要求与思考"></a>效果要求与思考</h2><p>如图所示，就是实现一个简单的城市排行榜</p>
<p><img src="https://gitee.com/lianghuilin/blog-image-warehouse/raw/master/20220407143942.png"></p>
<h3 id="几个注意要点"><a href="#几个注意要点" class="headerlink" title="几个注意要点"></a>几个注意要点</h3><ol>
<li>固定两列，两列之间有固定的空隙。但不固定有多少行，根据容器的高度自动填充多少行；</li>
<li>数据项先摆满第一列，再摆第二列；</li>
<li>布局要求有一定的适配性，数据项可以固定高度，但不能固定宽度（因为整个容器的宽就是通过vw单位自适应的）；</li>
<li>数据项要垂直居中；</li>
</ol>
<h3 id="Flex还是Grid"><a href="#Flex还是Grid" class="headerlink" title="Flex还是Grid"></a>Flex还是Grid</h3><p>其实文章标题就暴露了最终会用Grid布局来实现，但还是有小伙伴可能会质疑：“诶？你Grid能做的，我Flex布局一样能实现啊！实在不行，远古的table表格也可以一个个单元格，隔出来最终的效果啊？”</p>
<p>但平心而论，没有什么技术是银弹，jQuery一把梭也不是无敌，不过是适用什么场景而已。</p>
<p>我个人觉得，单行的线性布局适合用Flex布局，比如文本的排列；但平面的区域性布局，则用Grid更适合，比如九宫格啊之类的。<br>我们试着实现看看。</p>
<h2 id="最终案例"><a href="#最终案例" class="headerlink" title="最终案例"></a>最终案例</h2><iframe width="100%" height="300" src="//jsrun.net/CE9Kp/embedded/result,css/light" allowfullscreen="allowfullscreen" frameborder="0"></iframe>

<h2 id="Grid属性解读"><a href="#Grid属性解读" class="headerlink" title="Grid属性解读"></a>Grid属性解读</h2><h3 id="grid-template-columns设置网格的列宽"><a href="#grid-template-columns设置网格的列宽" class="headerlink" title="grid-template-columns设置网格的列宽"></a><code>grid-template-columns</code>设置网格的列宽</h3><p>取值方式有五种</p>
<ol>
<li>固定列宽，固定列数量</li>
</ol>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* 设置两列，每一列宽20像素 */</span></span><br><span class="line"><span class="selector-tag">grid-template-columns</span>: 20<span class="selector-tag">px</span> 20<span class="selector-tag">px</span>; </span><br><span class="line"><span class="comment">/* 通过repeat()函数，重复2列，列宽都是20像素 */</span></span><br><span class="line"><span class="selector-tag">grid-template-columns</span>: <span class="selector-tag">repeat</span>(2, 20<span class="selector-tag">px</span>);</span><br><span class="line"><span class="comment">/* 也可以设置百分比作为列宽 */</span></span><br><span class="line"><span class="selector-tag">grid-template-columns</span>: 33% 33% 33%;</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>固定列宽，不固定列数量</li>
</ol>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* 列宽20像素，但不确定有多少列，按照容器自动铺满 */</span></span><br><span class="line"><span class="selector-tag">grid-template-columns</span>: <span class="selector-tag">repeat</span>(<span class="selector-tag">auto-fill</span>, 20<span class="selector-tag">px</span>);</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>不固定列宽，固定列数量</li>
</ol>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* 设置两列，每一列占一份（相当于设置为50% 50%） */</span></span><br><span class="line"><span class="selector-tag">grid-template-columns</span>: 1<span class="selector-tag">fr</span> 1<span class="selector-tag">fr</span></span><br><span class="line"><span class="comment">/* 通用可以使用repeat()函数 */</span></span><br><span class="line"><span class="selector-tag">grid-template-columns</span>: <span class="selector-tag">repeat</span>(2, 1<span class="selector-tag">fr</span>)</span><br></pre></td></tr></table></figure>

<ol start="4">
<li>不固定列宽，也不固定列数量</li>
</ol>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* minmax函数：设置该列最小最大多宽 */</span></span><br><span class="line"><span class="selector-tag">grid-template-columns</span>: 1<span class="selector-tag">fr</span> 1<span class="selector-tag">fr</span> <span class="selector-tag">minmax</span>(300<span class="selector-tag">px</span>, 2<span class="selector-tag">fr</span>);</span><br><span class="line"><span class="comment">/* auto关键字：该列的宽度自适应，减去其他列的宽度后，所剩的宽度就是该列的宽度 */</span></span><br><span class="line"><span class="selector-tag">grid-template-columns</span>: 20<span class="selector-tag">px</span> <span class="selector-tag">auto</span> 20<span class="selector-tag">px</span>;</span><br></pre></td></tr></table></figure>

<ol start="5">
<li><code>[columnName]</code>指定列名称</li>
</ol>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* 设置了两列，第一列名称为c1，第二列名称为c2 */</span></span><br><span class="line"><span class="selector-tag">grid-template-columns</span>: <span class="selector-attr">[c1]</span> 20<span class="selector-tag">px</span> <span class="selector-attr">[c2]</span> 20<span class="selector-tag">px</span>;</span><br></pre></td></tr></table></figure>

<p>同理，设置行高的<code>grid-template-rows</code>属性，取值范围也是一样的</p>
<h3 id="grid-auto-column设置隐式网格"><a href="#grid-auto-column设置隐式网格" class="headerlink" title="grid-auto-column设置隐式网格"></a><code>grid-auto-column</code>设置隐式网格</h3><p>隐式网格与显式网格：摆放在Grid容器内的就是显式网格，摆放在容器外的就是隐式网格，也就是多出来的网格。<br>赋值规则和<code>grid-template-columns</code>是完全一样。</p>
<h3 id="grid-auto-flow控制布局算法"><a href="#grid-auto-flow控制布局算法" class="headerlink" title="grid-auto-flow控制布局算法"></a><code>grid-auto-flow</code>控制布局算法</h3><p>Grid布局中网格元素默认是以<code>grid-auto-flwo: row </code>“先行后列”的顺序进行摆放的，也就是“先摆满行，再摆列”</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.wrapper</span> &#123;</span><br><span class="line">  <span class="attribute">display</span>: grid;</span><br><span class="line">  <span class="attribute">grid-template-columns</span>: <span class="number">100px</span> <span class="number">200px</span> <span class="number">100px</span>;</span><br><span class="line">  <span class="attribute">grid-auto-flow</span>: row;</span><br><span class="line">  <span class="attribute">grid-gap</span>: <span class="number">5px</span>;</span><br><span class="line">  <span class="attribute">grid-auto-rows</span>: <span class="number">50px</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>上述的CSS布局效果如下</p>
<p><img src="https://gitee.com/lianghuilin/blog-image-warehouse/raw/master/20220407151350.png"></p>
<p>这里注意一下，Five之后空了一格，Six换行来摆放了。这也很容易理解，因为Six太胖了，摆不下了，而Seven认为自己是和Six是同一行的，所以就空了一格。那能不能让它自己怼上去呢？可以的，设置<code>grid-auto-flwo: row dense</code>成为紧凑布局就可以了，效果如下：</p>
<p><img src="https://gitee.com/lianghuilin/blog-image-warehouse/raw/master/20220407151800.png"></p>
<p>回到我们的案例，如果想反过来，先摆满每一列再摆满行，则可以改成<code>grid-auto-flwo: column</code>，看看One、Two的走向是不是先列后行</p>
<p><img src="https://gitee.com/lianghuilin/blog-image-warehouse/raw/master/20220407151910.png"></p>
<h3 id="grid-gap设置间隔"><a href="#grid-gap设置间隔" class="headerlink" title="grid-gap设置间隔"></a><code>grid-gap</code>设置间隔</h3><p><code>grid-gap</code>是<code>grid-column-gap</code>和<code>grid-row-gap</code>的简写属性，顾名思义，是设置列与列之间，行与行之间的空隙。<br>这个比较简单，就不多说了，但是Flex布局是没有gap属性，不能设置元素之间的空隙的，因为Flex布局的本质是线性布局。<br>通过这几个属性，以及Grid布局的特性，再对比一下Flex，哪个更灵活，我想你应该有答案了。<br>当然，Grid布局的兼容性也一直饱受争议，但不妨碍我们去学习它。</p>
<h2 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h2><ul>
<li><a target="_blank" rel="noopener" href="https://www.ruanyifeng.com/blog/2019/03/grid-layout-tutorial.html">阮一峰 - CSS Grid 网格布局教程</a></li>
<li><a target="_blank" rel="noopener" href="https://juejin.cn/post/6854573220306255880">Gopal - 最强大的CSS Grid布局</a></li>
</ul>

    </div>

    
    
    

    <footer class="post-footer">
          

<div class="post-copyright">
<ul>
  <li class="post-copyright-author">
      <strong>本文作者： </strong>William Leung
  </li>
  <li class="post-copyright-link">
      <strong>本文链接：</strong>
      <a href="https://gitee.com/lianghuilin/murmur.git/crush_notes/CSS%20Grid%E5%AE%9E%E7%8E%B0%E6%8E%92%E8%A1%8C%E6%A6%9C%EF%BC%8C%E6%8E%A7%E5%88%B6%E7%BD%91%E6%A0%BC%E7%9A%84%E6%B5%81%E5%8A%A8%E6%96%B9%E5%90%91/" title="CSS Grid实现排行榜，控制网格的流动方向">https://gitee.com/lianghuilin/murmur.git/crush_notes/CSS Grid实现排行榜，控制网格的流动方向/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/murmur/university_notes/Java(6)-%E7%BB%A7%E6%89%BF%E4%B8%8E%E5%A4%9A%E6%80%81/" rel="prev" title="计应本的自考笔记(6)-Java继承与多态">
                  <i class="fa fa-chevron-left"></i> 计应本的自考笔记(6)-Java继承与多态
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/murmur/crush_notes/%E4%B8%BA%E4%BB%80%E4%B9%88JS%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E8%A6%81%E6%94%BE%E6%A0%88%E5%86%85%E5%AD%98%EF%BC%9F/" rel="next" title="为什么JS基础数据类型要放栈内存？">
                  为什么JS基础数据类型要放栈内存？ <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






      

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      const activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      const commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

    </div>
  </main>

  <footer class="footer">
    <div class="footer-inner">
      

      

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">William Leung</span>
</div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
    <span title="站点总字数">142k</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">2:09</span>
  </span>
</div>
<div class="busuanzi-count">
    <span id="busuanzi_container_site_uv">
      本站访客数<span id="busuanzi_value_site_uv"></span>人次
    </span>
    <span id="busuanzi_container_site_pv">
        本站总访问量<span id="busuanzi_value_site_pv"></span>次
    </span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="//cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
<script src="/murmur/js/utils.js"></script><script src="/murmur/js/motion.js"></script><script src="/murmur/js/next-boot.js"></script>

  
















  <script>
    NProgress.configure({
      showSpinner: true
    });
    NProgress.start();
    document.addEventListener('readystatechange', () => {
      if (document.readyState === 'interactive') {
        NProgress.inc(0.8);
      }
      if (document.readyState === 'complete') {
        NProgress.done();
      }
    });
    document.addEventListener('pjax:send', () => {
      NProgress.start();
    });
    document.addEventListener('pjax:success', () => {
      NProgress.done();
    });
  </script>


  
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>








  

  

</body>
</html>
